/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.io.File;

/**
 * <p>Project: jse2303 - File1
 * <p>Powered by webrx On 2023-07-20 16:22:48
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class File1 {
    public static void main(String[] args) throws Exception {
        //实例化File类 的对象，项目根目录下的user.txt
        File file = new File("user.txt");
        System.out.println(file.getAbsolutePath());
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        System.out.println(file.getName());
        System.out.println(file.length());
        System.out.printf("%tF %<tT%n", file.lastModified());

        //exists()返回boolean表达file关联的对象，是否存在
        if (!file.exists()) {
            //建立一个空文件，0字节，时间为当前时间
            file.createNewFile();
        }
    }
}
